package com.lesso.yjy.sunflower.domain.service;

import com.baomidou.mybatisplus.plugins.Page;
import com.lesso.yjy.sunflower.domain.repository.AttendanceRuleRepository;
import com.lesso.yjy.sunflower.infra.assembler.AttendanceRuleAssembler;
import com.lesso.yjy.sunflower.model.AttendanceRule;
import com.lesso.yjy.sunflower.pojo.dto.AttendanceRuleDTO;
import com.lesso.yjy.sunflower.pojo.dto.AttendanceRuleQueryDTO;
import com.lesso.yjy.sunflower.pojo.vo.AttendanceRuleVO;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

@Service
public class AttendanceRuleDomainService {
    private final AttendanceRuleRepository attendanceRuleRepository;

    public AttendanceRuleDomainService(AttendanceRuleRepository attendanceRuleRepository) {
        this.attendanceRuleRepository = attendanceRuleRepository;
    }

    public Long save(AttendanceRuleDTO dto) {
        return attendanceRuleRepository.save(AttendanceRuleAssembler.INSTANCE.dtoToEntity(dto));
    }

    public Page<AttendanceRuleVO> page(AttendanceRuleQueryDTO dto) {
        return attendanceRuleRepository.getPageList(dto);
    }

    public Page<AttendanceRuleVO> customPage(AttendanceRuleQueryDTO dto) {
        return attendanceRuleRepository.getCustomPageList(dto);
    }

    public void deleteById(Long id) {
        attendanceRuleRepository.removeById(id);
    }

    public void update(AttendanceRuleDTO dto) {
        attendanceRuleRepository.updateById(dto);
    }

}
